# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# from AUR - adapted to you style
#
# Old Contributor: Luis Martinez <luis dot martinez at disroot dot org>
# Old Contributor: Christian Rebischke <chris.rebischke@archlinux.org>
# Old Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Old Contributor : Daniel Micay <danielmicay@gmail.com>

pkgname=gvm-libs
pkgver=22.22.0
pkgrel=1
pkgdesc='Greenbone Vulnerability Management Libraries.'
arch=('x86_64' 'aarch64')
url='https://github.com/greenbone/gvm-libs'
license=('GPL')
depends=('cjson' 'gnutls' 'hiredis' 'libgcrypt' 'libgio-2.0.so' 'libglib-2.0.so'
         'libgpgme.so' 'libldap' 'libnet' 'libssh.so' 'libuuid.so' 'libxml2.so'
         'paho-mqtt-c' 'zlib' 'libpcap')
makedepends=('cmake')
provides=(
  "libgvm_base.so=${pkgver::2}-64"
  "libgvm_boreas.so=${pkgver::2}-64"
  "libgvm_gmp.so=${pkgver::2}-64"
  "libgvm_osp.so=${pkgver::2}-64"
  "libgvm_util.so=${pkgver::2}-64")
replaces=('openvas-libraries')
source=("https://github.com/greenbone/gvm-libs/archive/v$pkgver.tar.gz")
sha256sums=('c97372197de5f6253580ef5f1083d32f1a2b0c47bfa4b54b60b1b87d31d1ca67')

PURGE_TARGETS=('var/run')

prepare() {
  cd "$pkgname-$pkgver"

  sed -i '/-Werror/d' CMakeLists.txt
}

build() {
  cmake \
    -B build \
    -S "$pkgname-$pkgver" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DLIBDIR=/usr/lib \
    -DSYSCONFDIR=/etc \
    -DLOCALSTATEDIR=/var

  make -C build
}

package() {
  make DESTDIR="${pkgdir}/" -C build install

  rm -rf "$pkgdir/run"
}

